{include file="public/header" /}
<style>
	
	#div-slide_show_pic{display:flex;flex-wrap:wrap;}
	.item-img {
		flex-direction: column;
		display: flex;
		margin-right: 18px;
		margin-bottom:17px;width:12%;text-align:center;
	}
	.item-img img{max-width: 100%;}
	.delMultipleImgs4{text-align:center;}
</style>
<style>

@font-face {

	font-family: 'FontAwesome';

	src: url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.eot?v=4.1.0');

	src: url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.eot?#iefix&v=4.1.0') format('embedded-opentype'), url('/css/fonts/fontawesome-webfont.woff?v=4.1.0') format('woff'), url('/css/fonts/fontawesome-webfont.ttf?v=4.1.0') format('truetype'), url('http://libs.baidu.com/fontawesome/4.1.0/fonts/fontawesome-webfont.svg?v=4.1.0#fontawesomeregular') format('svg');

	font-weight: normal;

	font-style: normal;

}

.icon-plus:before                 { content: "\f067"; }
.icon-minus:before                { content: "\f068"; }
[class^="icon-"]:before, [class*=" icon-"]:before {
  font-family: FontAwesome;
  font-weight: normal;
  font-style: normal;
  display: inline-block;
  text-decoration: inherit;
}
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>院系设置</h5>
                </div>
                <div class="ibox-content">

					<form id="formEdit" method="post" class="form-horizontal" action="{:url('school/edit_yuanxi')}">

	
						<div class="form-group">
							<label class="col-sm-2 control-label"><span style="color:red;">*&nbsp;</span>学院名称</label>
							<div class="input-group col-sm-4">{:isset($list.college_name)?$list.college_name:''}</div>
						</div>
                        
						<div class="form-group tese_major_group">
							<label class="col-sm-2 control-label"><span style="color:red;">&nbsp;</span>院系设置</label>
							<div> 
								<div class="input-group col-sm-10 field" style="display:none;float: right;"> 
									<input type="text" name="" placeholder="请输入院系名称" autocomplete="off" class="title" value="" >
									<textarea name="" class="major" style="width:50%;height:150px;"></textarea>
									
									<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus "></span>
								</div>
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-plus "></span>
							</div>
							<div style="clear:both;"></div>
							<div class="group2 input-group col-sm-8">
							{notempty name="yuanxi_list"}
							{volist name="yuanxi_list" id="vo"}
							<div class="input-group col-sm-9 field" style="float: right;">
								<input type="text" name="yuanxi[{$key}][title]" placeholder="请输入院系名称" autocomplete="off" class="title" value="{$vo['title']}" >
								
								<textarea name="yuanxi[{$key}][major]" class="major" style="width:50%;height:150px;">{:isset($vo.major)?$vo.major:''}</textarea>
								
								<span style="margin-right:5px;float: left;height: 33px;line-height: 33px;" class="icon-minus"></span>
							</div>
							{/volist}
							{/notempty}
							</div>
						</div>
						
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <div class="col-sm-4 col-sm-offset-3">
								<input type="hidden" name="id" value="{:isset($list['id'])?$list['id']:''}">
                                <button class="btn btn-primary" type="submit"><i class="fa fa-save"></i> 保存</button>&nbsp;&nbsp;&nbsp;
                                <a class="btn btn-danger" href="javascript:history.go(-1);"><i class="fa fa-close"></i> 返回</a>
                            </div>
                        </div>
					</form>

                </div>
            </div>

        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/select2/select2.js"></script>
<link href="/static/admin/js/select2/css/select2.min.css?20191202" rel="stylesheet" type="text/css" />

<script type="text/javascript">
	$('.select2').select2({
		allowClear: true,
		width: '80%',
		minimumResultsForSearch: 1,
		placeholder: {
			'id': "",
			'text': "请选择",
		}
	});
	
		
		
		var j = "{$yuanxi_count}";
		$('.tese_major_group').on('click','.icon-plus',function(){
			var html = $(this).parent().find('.field').clone();
			html.css('display','');
			html.find(".title").attr('name','yuanxi['+j+'][title]');
			html.find(".major").attr('name','yuanxi['+j+'][major]');
			$(this).closest('.form-group').children(".group2").append(html); 
			j++;	

		})   
		$('.group2').on('click','.icon-minus',function(){
			$(this).closest('.field').remove();
			//$(".group2 .field").each((h,item)=>{
			//	$(item).find(".title").attr('name','yuanxi['+h+'][title]');
			//	$(item).find(".major").attr('name','yuanxi['+h+'][major]');
			//});
			//j--;
		})
		
    //提交
    $(function(){
        $('#formEdit').ajaxForm({
            beforeSubmit: checkForm, 
            success: complete, 
            dataType: 'json'
        });
        
        function checkForm(){
            
        }


        function complete(data){
            if(data.code==1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    window.location.href="{:url('school/index')}";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1});
                return false;   
            }
        }
     
    });

</script>
</body>
</html>